import os
os.getcwd()
os.chdir(r"C:\Users\justin.zou\Desktop\3007260")
def ListFilesToTxt(dir,file,wildcard,recursion):
    exts = wildcard.split(" ")
    for root, subdirs, files in os.walk(dir):
        for name in files:
            for ext in exts:
                if(name.endswith(ext)):
                    file.write(name + "\n")
                    break
        if(not recursion):
            break

def Test():
  dir=(r"C:\Users\justin.zou\Desktop\3007260")
  outfile="binaries.txt"
  wildcard = ".txt .exe .dll .lib .csv"
 
  file = open(outfile,"w")
#   for line in file.readlines():
#       print(line)
#       str1=line.split('#',1)
#       print(str1)

  if not file:
    print ("cannot open the file %s for writing" % outfile)

  ListFilesToTxt(dir,file,wildcard, 0)
 
  file.close()

Test()